DROP VIEW [dbo].[vi0317]
GO
CREATE VIEW [dbo].[vi0317] AS 
SELECT	ID,
 (Case When  TranMonth <10 then '0'+rtrim(ltrim(str(TranMonth)))+'/'+ltrim(Rtrim(str(TranYear))) 
	Else rtrim(ltrim(str(TranMonth)))+'/'+ltrim(Rtrim(str(TranYear))) End) as MonthYear,

	('0'+ ltrim(rtrim(Case when TranMonth %3 = 0 then TranMonth/3  Else TranMonth/3+1  End))+'/'+ltrim(Rtrim(str(TranYear)))
	)
	  as Quarter ,

	TranMonth,
	TranYear,
	DivisionID,
	GroupShow
From tb0199 Where Disabled <> 1
Union ALL
SELECT ID,
 (Case When  TranMOnth <10 then '0'+rtrim(ltrim(str(TranMonth)))+'/'+ltrim(Rtrim(str(TranYear))) 
	Else rtrim(ltrim(str(TranMonth)))+'/'+ltrim(Rtrim(str(TranYear))) End) as MonthYear,

	('0'+ ltrim(rtrim(Case when TranMonth %3 = 0 then TranMonth/3  Else TranMonth/3+1  End))+'/'+ltrim(Rtrim(str(TranYear)))
	)
	  as Quarter ,

	TranMonth,
	TranYear,
	'%' as DivisionID,
	GroupShow
From tb0199
Where DivisionID in (Select Top 1 DivisionID From tb0199 )

GO